//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Chart
{
    internal class Level : IOfficeXmlSerializable
    {
        private List<StringValue> _values = new List<StringValue>();
        internal const string xmlName = "lvl";
        /// <summary>
        /// Generates an object from its XML representation
        /// </summary>
        /// <param name="context"></param>
        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read(xmlName))
            {
                _values.Clear();
                _values.AddRange(c.ReadOptionalWhile<StringValue>("pt"));
            }
        }

        /// <summary>
        /// Convert an object into its XML representation
        /// </summary>
        /// <param name="context"></param>
        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write(xmlName))
            {
                c.WriteElements(_values);
            }
        }
    }
}